import 'package:flutter/material.dart';

class SearchField extends StatelessWidget {
  final String? hintText;
  final VoidCallback? onEditingComplete;
  final TextEditingController? searchController;
  final FocusNode? searchfocusNode;
  const SearchField({
    super.key,
    this.hintText = "请输入关键词",
    this.onEditingComplete,
    this.searchController,
    this.searchfocusNode,
  });

  @override
  Widget build(BuildContext context) {
    return TextField(
      style: const TextStyle(fontSize: 16),
      controller: searchController,
      textInputAction: TextInputAction.done,
      textAlign: TextAlign.left,
      onEditingComplete: onEditingComplete,
      focusNode: searchfocusNode,
      decoration: InputDecoration(
          hintText: hintText, //prefix: Icon(Icons.search),
          prefixIcon: const Icon(Icons.search),
          border: const OutlineInputBorder(
            borderRadius: BorderRadius.all(Radius.circular(25)),
          ),
          suffixIcon: IconButton(
            icon: const Icon(Icons.close),
            onPressed: () {
              searchController!.clear();
              searchfocusNode!.unfocus();
            },
          )),
    );
  }
}
